package com.ufenlei.LTS {
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.display.Sprite;

	/**
	 * @author bbn
	 */
	public class TextBlock extends Sprite {
		private var tf:TextField;
		private var h:int;
		private var w:int;
		private var centerformat:TextFormat = new TextFormat();
		private var leftformat :TextFormat = new TextFormat();
		public function TextBlock(bwidth : uint = 100, bheight : uint = 100) {
			tf = new TextField();
			this.addChild(tf);
			w = bwidth;
			h = bheight;
			tf.width = w;
			tf.height= h;
			centerformat.align = "center";
			leftformat.align = "left";
			
		}
		public function get text():String{
			return tf.text;
		}
		public function set text(displayText:String):void{
			this.tf.text = displayText;
			if(displayText.length < 30){
				tf.height = 30;
				tf.y = (h - 30)/2;
				tf.setTextFormat(centerformat);
			}else{
				tf.height = h;
				tf.y =0 ;
				tf.setTextFormat(leftformat);
			}
		}
	}
}
